@(pathList: List[String],
  branch: String,
  repository: gitbucket.core.service.RepositoryService.RepositoryInfo,
  commits: Seq[Seq[(gitbucket.core.util.JGitUtil.CommitInfo, List[String], Option[(gitbucket.core.model.CommitState, List[gitbucket.core.model.CommitStatus])])]],
  page: Int,
  hasNext: Boolean,
  hasWritePermission: Boolean)(implicit context: gitbucket.core.controller.Context)
@import gitbucket.core.view.helpers
@gitbucket.core.html.main(s"${repository.owner}/${repository.name}", Some(repository)) {
  @gitbucket.core.html.menu("files", repository){
    <div class="head">
      @if(pathList.isEmpty){
        @gitbucket.core.helper.html.branchcontrol(branch, repository, hasWritePermission){
          @repository.branchList.map { x =>
            <li><a href="@helpers.url(repository)/commits/@helpers.encodeRefName(x)">@gitbucket.core.helper.html.checkicon(x == branch) @x</a></li>
          }
        }
      }
      @if(pathList.nonEmpty){
        <span class="muted">History for</span>
        <a class="strong" href="@helpers.url(repository)/tree/@helpers.encodeRefName(branch)">@repository.name</a> /
        @pathList.zipWithIndex.map { case (section, i) =>
          @if(i == pathList.length - 1){
            <span class="strong">@section</span>
          } else {
            <a class="strong" href="@helpers.url(repository)/tree/@helpers.encodeRefName((branch :: pathList.take(i + 1)).mkString("/"))">@section</a> /
          }
        }
      }
    </div>

    <table class="table table-bordered table-hover">
    @commits.map { day =>
      <tr>
        <th rowspan="@day.size" width="100">@helpers.date(day.head._1.commitTime)</th>
        @day.zipWithIndex.map { case ((commit, tags, status), i) =>
          @if(i != 0){ <tr> }
          <td>
            <div class="pull-right text-right">
              @if(commit.commitSign.isDefined){
                @commit.verified.map{ v =>
                  <span class="gpg-verified" data-toggle="tooltip" title="Signed by @v.signedUser (@v.signedKeyId)">Verified</span>
                }.getOrElse{
                  <span class="gpg-unverified">Unverified</span>
                }
              }
              @if(tags.nonEmpty){
                <span class="muted">
                  <i class="octicon octicon-tag"></i>
                  @tags.map { tag =>
                    <a href="@helpers.url(repository)/tree/@tag" class="tag">@tag</a>
                  }
                </span>
              }
              <a href="@helpers.url(repository)/commit/@commit.id" class="monospace commit-message strong"><i class="octicon octicon-diff" style="color: black;"></i>@commit.id.substring(0, 7)</a><br>
              <a href="@helpers.url(repository)/tree/@commit.id" class="button-link">Browse files »</a>
            </div>
            <div>
              <div class="commit-avatar-image">@helpers.avatarLink(commit, 40)</div>
              <div>
                @helpers.link(commit.summary, repository)
                @if(commit.description.isDefined){
                  <a href="javascript:void(0)" onclick="$('#description-@commit.id').toggle();" class="omit">...</a>
                }
                <br>
                @if(commit.description.isDefined){
                  <pre id="description-@commit.id" style="display: none;" class="commit-description">@helpers.link(commit.description.get, repository)</pre>
                }
                  <div>
                  @if(commit.isDifferentFromAuthor) {
                    @helpers.user(commit.authorName, commit.authorEmailAddress, "username")
                    <span class="muted">authored @gitbucket.core.helper.html.datetimeago(commit.authorTime)</span>
                    <span class="octicon octicon-arrow-right" style="margin-top : -2px;"></span>
                  }
                  @helpers.user(commit.committerName, commit.committerEmailAddress, "username")
                  <span class="muted">committed @gitbucket.core.helper.html.datetimeago(commit.commitTime)</span>
                  @status.map { case (summary, statuses) =>
                    @gitbucket.core.helper.html.commitstatus(commit.id, summary, statuses)
                  }
                </div>
              </div>
            </div>
          </td>
          </tr>
        }
    }
    </table>

    <nav style="text-align: center; margin-top: 20px">
      <ul class="pagination">
        @if(page <= 1){
          <li class="disabled"><span>Newer</span></li>
        } else {
          <li><a href="?page=@{page - 1}">Newer</a></li>
        }
        @if(!hasNext){
          <li class="disabled"><span>Older</span></li>
        } else {
          <li><a href="?page=@{page + 1}">Older</a></li>
        }
      </ul>
    </nav>
    <script>
      $(function() {
        $('[data-toggle="tooltip"]').tooltip();
      });
    </script>
    <style type="text/css">
      a.tag {
        color: #888888;
        margin-right: 4px;
      }
    </style>
  }
}
